package com.example.home_model.details;

import android.view.View;
import android.widget.ImageView;

import com.alibaba.android.arouter.launcher.ARouter;
import com.blankj.utilcode.util.LogUtils;
import com.example.baseadapter_sdk.BaseQuickAdapter;
import com.example.baseadapter_sdk.BaseViewHolder;
import com.example.common.providerservice.CheckLoginAPI;
import com.example.home_model.R;
import com.example.home_model.details.entity.commententity.CommentDataDTO;

import java.text.SimpleDateFormat;

public class CommentAdapter extends BaseQuickAdapter<CommentDataDTO> {

    private SimpleDateFormat simpleDateFormat;
    private CheckLoginAPI checkLoginAPI;

    public CommentAdapter() {
        super(R.layout.item_comment);
        checkLoginAPI = (CheckLoginAPI) ARouter.getInstance().build("/user/checklogin").navigation();
        addItemChildClick(R.id.itemCommentDel);
    }

    @Override
    public void convert(BaseViewHolder holder, CommentDataDTO item) {
        holder.setText(R.id.itemCommentTitle, item.author.name);
        holder.setText(R.id.itemCommentText, item.commentText);
        simpleDateFormat = new SimpleDateFormat("YYYY:MM:dd HH:mm:ss");
        String format = simpleDateFormat.format(item.createTime);
        holder.setText(R.id.itemCommentTime, format);
        ImageView img_del = holder.getView(R.id.itemCommentDel);
        LogUtils.e("UserId"+checkLoginAPI.getUserId());

        holder.setVisibility(R.id.itemCommentDel, checkLoginAPI.getUserId()==item.userId);

    }
}
